<template>
  <div>
    <div class="form-body" v-loading="loading">
      <step :step="1"></step>
      <div class="form-title">
        <span>{{ info.name }}</span>
        <span class="form-title-color" v-if="info.type_name">·{{ info.type_name }}</span>
      </div>
      <el-divider content-position="center">填写投保信息</el-divider>
      <div class="form-window">
        <div class="form-window-line"></div>
        <div class="form-window-txt">保障方案</div>
      </div>
      <div class="form-form">
        <el-form label-position="left" label-width="140px" size="small">
          <!-- <el-form-item label="投保时长">
            <el-button
              :disabled="edit"
              size="small"
              @click="selectTime(index, item)"
              :class="timeName === item.name ? 'com-btn' : ''"
              v-for="(item, index) in info.dt_level"
              :key="index"
              >{{ item.name }}
            </el-button>
          </el-form-item> -->

          <el-form-item :label="info.level_name" v-if="info.level_num > 1">
            <!-- <div style="display: flex">
              <div style="margin-right: 20px; width: 60px; color: #333333">三个月:</div>
              <el-button
                :disabled="edit"
                size="small"
                @click="selectDjFanan(item, index)"
                :class="level_id == item.id ? 'com-btn btns' : ' btns'"
                v-for="(item, index) in info.level"
                v-show="index < 2"
                :key="'djf' + index"
                >{{ item.name }}
              </el-button>
            </div> -->
            <div style="display: flex">
              <div style="margin-right: 20px; width: 60px; color: #333333">六个月:</div>
              <el-button :disabled="edit" size="small" @click="selectDjFanan(item, index)"
                :class="level_id == item.id ? 'com-btn btns' : 'btns'" v-for="(item, index) in info.level"
                v-show="index < 2" :key="'djf' + index">{{ item.name }}
              </el-button>
            </div>
            <div style="display: flex">
              <div style="margin-right: 20px; width: 60px; color: #333333">一年:</div>
              <!-- index >= 4 && index < 6  -->
              <el-button :disabled="edit" size="small" style="margin-left: 0; margin-right: 15px"
                @click="selectDjFanan(item, index)" :class="level_id == item.id ? 'com-btn' : ''"
                v-for="(item, index) in info.level" v-show="index >= 2 && index < 4" :key="'djf' + index">{{ item.name
                }}
              </el-button>
            </div>
          </el-form-item>
          <el-form-item label="充电桩功率" v-if="info.id == 15">
            <el-button :disabled="edit" size="small" @click="selectCdj(item, index)"
              :class="level_name === item.name ? 'com-btn fanan-btn' : 'fanan-btn'" v-for="(item, index) in info.level"
              :key="index">{{ item.name }}
            </el-button>
          </el-form-item>
          <el-form-item :label="fananText">
            <el-button :disabled="edit" size="small" @click="selectFanan(index, item)"
              :class="fanan === item.name ? 'com-btn' : ''" v-for="(item, index) in chooseDta.plan" :key="index">{{
                item.name }}
            </el-button>
          </el-form-item>
          <el-form-item label="财产保额" v-if="info.id == 15">
            <el-button :disabled="edit" size="small" @click="selectCcbe(index, item)"
              :class="property_type === item.name ? 'com-btn fanan-btn' : 'fanan-btn'" v-for="(item, index) in ccbe_arr"
              :key="index">{{ item.name }}
            </el-button>
          </el-form-item>
          <el-form-item label="第三者责任险" v-if="info.is_third">
            <div v-if="info.third_true == 0">
              <el-button :disabled="edit" @click="selectIsThird(1)" :class="is_third == 1 ? 'com-btn' : ''">投保
              </el-button>
              <el-button :disabled="edit" @click="selectIsThird(0)" :class="is_third == 0 ? 'com-btn' : ''"
                v-show="info.third_true == 0">不投保
              </el-button>
            </div>
            <div v-else>
              <el-button :disabled="edit" @click="selectIsThird(1)" :class="is_third == 1 ? 'com-btn' : ''">投保
              </el-button>
            </div>
          </el-form-item>
          <el-form-item label="扩展火灾爆炸责任险" v-if="id == 9">
            <el-button :disabled="edit" @click="selectIsFire(1)" :class="is_fire == 1 ? 'com-btn' : ''">投保
            </el-button>
            <el-button :disabled="edit" @click="selectIsFire(0)" :class="is_fire == 0 ? 'com-btn' : ''"
              v-show="info.third_true == 0">不投保
            </el-button>
          </el-form-item>
          <el-form-item label="新机完工责任险" v-if="info.is_finished">
            <el-button :disabled="edit" @click="selectIsF(1)" :class="is_four == 1 ? 'com-btn' : ''">投保
            </el-button>
            <el-button :disabled="edit" v-show="info.finished_true == 0" @click="selectIsF(0)"
              :class="is_four == 0 ? 'com-btn' : ''">不投保
            </el-button>
          </el-form-item>
          <el-form-item label="盗抢险" v-if="info.is_rob">
            <el-button :disabled="edit" @click="selectRob(1)" :class="is_rob == 1 ? 'com-btn' : ''">投保
            </el-button>
            <el-button :disabled="edit" @click="selectRob(0)" :class="is_rob == 0 ? 'com-btn' : ''">不投保
            </el-button>
          </el-form-item>
          <el-form-item label="扩展24小时意外" v-if="info.id == 4"></el-form-item>
        </el-form>
        <el-card shadow="never" class="fanan-card" v-if="fanan && info.id != 10 && info.id != 15">
          <div class="fanan-card-item" v-if="flfy_name">
            <div class="fanan-card-item-left">法律费用</div>
            <div class="fanan-card-item-right">{{ flfy_name }}</div>
          </div>
          <div class="fanan-card-item" v-if="wg_name">
            <div class="fanan-card-item-left">误工费用</div>
            <div class="fanan-card-item-right">{{ wg_name }}</div>
          </div>
          <div class="fanan-card-item" v-if="ylfy_name">
            <div class="fanan-card-item-left">医疗费用</div>
            <div class="fanan-card-item-right">{{ ylfy_name }}</div>
          </div>
          <div class="fanan-card-item" v-if="info.type == 2">
            <div class="fanan-card-item-left">住院津贴</div>
            <div class="fanan-card-item-right">{{ zyjt_name }}</div>
          </div>
          <div class="fanan-card-item" v-if="info.id == 4 && id != 9">
            <div class="fanan-card-item-left">扩展24小时</div>
            <div class="fanan-card-item-right"></div>
          </div>
          <div v-if="info.id == 11">财产综合险{{ fanan }}+公众责任险{{ gzzrx_name }}</div>
        </el-card>
        <el-card shadow="never" class="fanan-card" v-if="Third" style="margin-top: 10px">
          <div class="fanan-card-item" style="width: 100%">
            <div class="fanan-card-item-left">第三者责任</div>
            <div class="fanan-card-item-right">
              <span style="line-height: 25px">
                {{ info.third_memo }}
              </span>
            </div>
          </div>
        </el-card>
        <el-card shadow="never" class="fanan-card" v-if="is_fire" style="margin-top: 10px">
          <div class="fanan-card-item" style="width: 100%">
            <div class="fanan-card-item-left">火灾责任险</div>
            <div class="fanan-card-item-right">
              <span style="line-height: 25px">
                {{ info.fire_memo }}
              </span>
            </div>
            <!-- <div class="fanan-card-item-right" v-if="info.id == 9">
              <span v-if="info.id == 9">
                充电设备在投保使⽤后，在正常使⽤过程中发⽣意外事故造成三者的⼈身伤亡和财产损失依法
                应由被保险⼈承担的经济赔偿责任，保险⼈负责赔偿。
                可选：扩展火灾爆炸责任。
                免赔：每次事故财产损失绝对免赔为RMB1000元或损失金额10%（以高者为准）。
              </span>
            </div> -->
          </div>
        </el-card>
        <el-card shadow="never" class="fanan-card" v-if="is_finished" style="margin-top: 10px">
          <div class="fanan-card-item" style="width: 100%">
            <div class="fanan-card-item-left">新机完工责任险</div>
            <div class="fanan-card-item-right">
              <div style="text-align: left; flex: 1; line-height: 26px; padding: 0px 10px">
                {{ info.finished_memo }}
              </div>
            </div>
          </div>
        </el-card>
        <div class="form-btn-box">
          <div style="margin-right: 80px; font-size: 18px; font-weight: bold; color: #ed0009">
            保费：￥{{ Number(cost).toFixed(2) }}
            <span v-if="info.id == 9">/ 桩</span>
            <span v-if="info.id != 9 && info.id != 10"></span>
            <span v-if="info.id != 15">/ 人</span>
            <!-- {{ id == 9 ? "/ 桩" : "/ 人" }} -->
          </div>
          <el-button size="small" @click="updateInfoItem(1)">修改</el-button>
          <el-button size="small" class="com-btn" @click="saveStorage(1)">保存
          </el-button>
        </div>
      </div>

      <div class="form-window" v-if="info.id != 10 && info.id != 15">
        <div class="form-window-line"></div>
        <div class="form-window-txt">投保企业</div>
        <div class="form-window-btn">
          <el-button :disabled="user_edit" size="mini" @click="history()" type="text">历史信息
          </el-button>
        </div>
      </div>
      <div class="form-form" v-if="info.id != 10 && info.id != 15">
        <el-form :disabled="insure.edit" label-position="left" label-width="140px" size="small">
          <el-form-item label="投保人类型" v-if="info.id == 12">
            <el-button :disabled="edit" size="small" @click="clickTabs(index)" :class="item.isActive ? 'com-btn' : ''"
              v-for="(item, index) in tabs" :key="'djf' + index">{{ item.name }}
            </el-button>
          </el-form-item>
          <div v-if="insure.type == 1">
            <el-form-item label="营业执照">
              <div class="form-uplopad-box">
                <upload v-if="info.type != 2" :img_url="insure.license" file_name="insure/license"
                  @change="upInsure($event, -1)" @changeKey="upLicenseKey"></upload>
                <upload2 v-if="info.type == 2" :img_url="insure.license" file_name="insure/license"
                  @change="upInsure($event, -1)" @changeKey="upLicenseKey"></upload2>
                <div class="form-uplopad-box-txt">示例</div>
                <img src="../../assets/img/yyzz.png" class="form-uplopad-box-img" />
                <div class="form-uplopad-box-no" v-if="insure.edit"></div>
              </div>
            </el-form-item>
            <el-form-item label="企业名称">
              <el-input placeholder="请输入企业名称" @blur="qiyeName()" v-model="insure.name" class="form-input"></el-input>
            </el-form-item>
            <el-form-item label="统一信用编码">
              <el-input placeholder="请输入统一信用编码" @blur="qiyeNo()" v-model="insure.client" class="form-input"></el-input>
            </el-form-item>
            <el-form-item label="法人">
              <el-input placeholder="请输入法人" v-model="insure.contact" class="form-input"></el-input>
            </el-form-item>
            <el-form-item label="手机号码">
              <el-input placeholder="请输入手机号码" v-model="insure.contact_mobile" class="form-input">
                <template slot="append" v-if="info.id != 12">
                  <el-checkbox v-model="insure.is_manage">批改权限</el-checkbox></template>
              </el-input>
            </el-form-item>
            <div style="color: red; margin-left: 141px; margin-bottom: 13px" v-if="info.id != 12">
              勾选后，确认您授权给该号码持有人在投保后批改批增人员的相关权限，点击<a href="https://meimi.nabx.cn/selectpage/#/">进入批改页面</a>。
            </div>
            <el-form-item label="所属省市区">
              <el-cascader class="form-input" @change="changeAddress" :props="propsAddress" :options="optionsAddress"
                :placeholder="insure.modelPGR ? insure.modelPGR : '请选择省市区'">
              </el-cascader>
            </el-form-item>

            <el-form-item label="办公地址">
              <div class="form-address">
                <!--<el-select v-model="insure.province" @change="changeInsureProvince()" class="form-seletc" >
                              <el-option v-for="(item,key) in insure_pro" :key="'insure'+key" :label="item.label" :value="item.label" ></el-option>
                            </el-select>
                            <el-select v-model="insure.city"  @change="changeInsureCity()" class="form-seletc">
                              <el-option v-for="(item,key) in insure_city" :key="'insure'+key" :label="item.label" :value="item.label" ></el-option>
                            </el-select>
                            <el-select v-model="insure.area"  class="form-seletc">
                              <el-option v-for="(item,key) in insure_area" :key="'insure'+key" :label="item.label" :value="item.label" ></el-option>
                            </el-select>-->
                <el-input placeholder="请输入办公地址" v-model="insure.address" class="form-input"></el-input>
              </div>
            </el-form-item>
          </div>
          <div v-if="insure.type == 2">
            <el-form-item label="投保人">
              <div>
                <el-input v-model="insure.name" placeholder="请输入" class="form-input"></el-input>
              </div>
            </el-form-item>
            <el-form-item label="证件类型">
              <div>
                <el-input v-model="cardType" :disabled="true" class="form-input"></el-input>
              </div>
            </el-form-item>
            <el-form-item label="证件号码">
              <div>
                <el-input v-model="insure.client" placeholder="请输入" class="form-input"></el-input>
              </div>
            </el-form-item>
            <el-form-item label="手机号码">
              <div>
                <el-input v-model="insure.contact_mobile" placeholder="请输入" class="form-input"></el-input>
              </div>
            </el-form-item>
          </div>
        </el-form>
        <div class="form-btn-box">
          <el-button size="small" @click="updateInfoItem(2)">修改</el-button>
          <el-button size="small" class="com-btn" @click="saveStorage(4)">保存
          </el-button>
        </div>
      </div>
      <!-- 投保人信息 -->
      <div v-if="info.id == 10 || info.id == 15">
        <insureProfile :edit="insureProfile_edit" :optionsHyAddress="optionsHyAddress" :propsHyAddress="propsHyAddress"
          @saveStorage="saveStorage" @updateInfoItem="updateInfoItem" :insure="hyParam.insure" ref="insureProfileRef"
          :types="info.type" @seletcHis="seletcHis" @insureClickTabs="insureClickTabs" @upLicenseKey="upLicenseKey"
          @upInsure="upInsure" @qiyeName="qiyeName" @qiyeNo="qiyeNo">
        </insureProfile>
      </div>
      <!-- 被保人信息 -->
      <div v-if="info.id == 10 || info.id == 15">
        <insuredProfile :edit="insuredProfile_edit" :optionsHyAddress="optionsHyAddress"
          :propsHyAddress="propsHyAddress" @saveStorage="saveStorage" @updateInfoItem="updateInfoItem"
          :insured="hyParam.insured" @clickCheck="clickCheck" ref="insuredProfileRef" @upLicenseKey="upLicenseKey"
          @upInsure="upInsure">
        </insuredProfile>
      </div>
      <!-- 运输信息 -->
      <div v-if="info.id == 10">
        <yunProfile :edit="yunProfile_edit" :optionsHyAddress="optionsHyAddress" :propsHyAddress="propsHyAddress"
          @saveStorage="saveStorage" @updateInfoItem="updateInfoItem" :transport="hyParam.transport"></yunProfile>
      </div>
      <!-- 货物信息 -->
      <div v-if="info.id == 10">
        <goodsProfile :edit="goodsProfile_edit" @saveStorage="saveStorage" @updateInfoItem="updateInfoItem"
          :goods="hyParam.goods">
        </goodsProfile>
      </div>
      <!-- 被保企业 -->
      <div v-if="info.id == 11">
        <insuredBus :edit="insuredBus_edit" @saveStorage="saveStorage" @updateInfoItem="updateInfoItem"
          :merchant="shParam.merchant"></insuredBus>
      </div>
      <!-- 营业场所信息 -->
      <div v-if="info.id == 11">
        <businessPlace :edit="businessPlace_edit" :optionsAddress="optionsAddress" @saveStorage="saveStorage"
          @updateInfoItem="updateInfoItem" :propsAddress="propsAddress" :premises="shParam.premises"></businessPlace>
      </div>

      <div class="form-window" v-if="showTestFeatures && info.id != 15">
        <div class="form-window-line"></div>
        <div class="form-window-txt">
          其他共同被保险人
          <span style="color: red">说明：请按实际情况填写其它共同被保险人的相关信息，主被保险人默认为投保人无须填写。</span>
        </div>
        <div class="form-window-btn">
          <el-button :disabled="user_edit" size="mini" @click="addBei()" type="text">添加其他共同被保险人
          </el-button>
        </div>
      </div>
      <div class="form-form" v-if="showTestFeatures && info.id != 15">
        <div v-if="open_arr.length > 0">
          <el-card v-for="(item, key) in open_arr" :key="'open' + key" shadow="never" :style="{
            marginTop: key == 0 ? '0' : '10px',
            position: 'relative',
          }">
            <el-form :disabled="edit_other" label-position="left" label-width="140px" size="small">
              <el-form-item label="企业名称">
                <el-input placeholder="请输入企业名称" @blur="qiyeName()" v-model="item.name" class="form-input"></el-input>
              </el-form-item>
              <el-form-item label="统一信用编码">
                <el-input placeholder="请输入统一信用编码" @blur="qiyeNo()" v-model="item.client" class="form-input"></el-input>
              </el-form-item>
              <el-form-item label="法人">
                <el-input placeholder="请输入法人" v-model="item.contact" class="form-input"></el-input>
              </el-form-item>
              <el-form-item label="手机号码">
                <el-input placeholder="请输入手机号码" v-model="item.contact_mobile" class="form-input"></el-input>
              </el-form-item>
            </el-form>
            <el-button icon="el-icon-delete" @click="deleteOpenArr(key)" class="open-delete" size="mini"
              type="danger"></el-button>
            <el-button @click="editOpenArr(key)" class="open-edit" size="mini" type="text">历史记录</el-button>
          </el-card>
        </div>
        <div v-else class="open-empty">暂无其他共同被保险企业</div>
        <!--<el-form :disabled="edit_other" label-position="left" label-width="140px" size="small">
                  <el-form-item label="增加其他被保企业" >
                    <el-switch v-model="is_open" active-text="是" inactive-text="否"></el-switch>
                  </el-form-item>
                  <div v-if="is_open">
                    <el-form-item label="企业名称" >
                      <el-input v-model="open_name" type="textarea" placeholder="多家企业用'、'分割" ></el-input>
                    </el-form-item>
                    <el-form-item label="统一信用编码" >
                      <el-input v-model="open_no" type="textarea" placeholder="多家企业的统一信用编码用'、'分割" ></el-input>
                      &lt;!&ndash;<el-input v-model="open_no"  placeholder="请使用其中一家企业的统一信用编码" ></el-input>&ndash;&gt;
                    </el-form-item>
                  </div>
                </el-form>-->
        <div class="form-btn-box" v-if="is_open">
          <el-button size="small" @click="updateInfoItem(6)">修改</el-button>
          <el-button size="small" class="com-btn" @click="saveStorage(6)">保存
          </el-button>
        </div>
      </div>
      <div class="form-window" v-if="info.id != 10">
        <div class="form-window-line"></div>
        <div class="form-window-txt">保单生效日期</div>
      </div>
      <div class="form-form" v-if="info.id != 10">
        <el-form :disabled="time_eidt" label-position="left" label-width="140px" size="small">
          <!-- <el-form-item label="当前日期">{{ now_time }}</el-form-item> -->
          <el-form-item label="生效日期">
            <el-date-picker @change="selectStartTime()" v-model="start_time" :picker-options="pickerOptions" type="date"
              placeholder="选择日期" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss">
            </el-date-picker>
            <span style="color: #f95d4a; margin-left: 10px"
              v-if="info.id != 10 && info.id != 12 && info.id != 15">最长可提前3个月投保</span>
          </el-form-item>
          <el-form-item label="失效日期">
            <el-date-picker v-model="end_time" @change="selectEndTime()" type="date" placeholder="失效日期"
              :readonly="info.id == 10 ? false : true" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss">
            </el-date-picker>
          </el-form-item>
        </el-form>
        <div class="form-btn-box">
          <el-button size="small" @click="updateInfoItem(3)">修改</el-button>
          <el-button size="small" class="com-btn" @click="saveStorage(5)">保存
          </el-button>
        </div>
      </div>
      <div class="form-window" v-if="info.id == 9 || info.id == 15">
        <div class="form-window-line"></div>
        <div class="form-window-txt">充电桩信息</div>
      </div>
      <div class="form-form" v-if="info.id == 9 || info.id == 15">
        <el-form :disabled="cdzProfile_edit" label-position="left" label-width="140px" size="small">
          <el-form-item label="充电桩地址">
            <el-cascader class="form-input" @change="changecdzAddress" :props="propsAddress" :options="optionsAddress"
              :placeholder="charge_info.modelPGR ? charge_info.modelPGR : '请选择省市区'"></el-cascader>
          </el-form-item>
          <el-form-item label="详细地址">
            <el-input placeholder="请输入详细地址" v-model="charge_info.address" class="form-input"></el-input>
          </el-form-item>
          <el-form-item label="充电桩编号、S/N">
            <el-input placeholder="请输入充电桩编号、S/N" v-model="charge_info.number" class="form-input"></el-input>
          </el-form-item>
          <el-form-item label="充电桩数量" v-if="!showTestFeatures">
            <el-input placeholder="请输入充电桩数量" :disabled="true" v-model="charge_info.num" class="form-input"></el-input>
          </el-form-item>
          <el-form-item label="充电桩面积">
            <el-input placeholder="请输入充电桩面积" v-model="charge_info.area_num" class="form-input"></el-input> <span
              v-if="showTestFeatures" style="margin-left: 5px;">m²</span>
          </el-form-item>
        </el-form>
        <div class="form-btn-box">
          <el-button size="small" @click="updateInfoItem(14)">修改</el-button>
          <el-button size="small" class="com-btn" @click="saveStorage(14)">保存
          </el-button>
        </div>
      </div>
      <div class="form-window" style="border-bottom: 1px solid #eeeeee; padding-bottom: 20px"
        v-if="info.type == 2 && info.id != 12">
        <div class="form-window-line"></div>
        <div class="form-window-txt">
          附件
          <span style="color: red">(支持上传人员名单文件或者名单截图)</span>
        </div>
        <div class="form-window-btn">
          <el-button :disabled="user_edit" size="mini" class="com-btn" style="position: relative"
            :loading="uploadUserLoading">
            {{ key_from.personnel_key ? "已上传人员名单" : "上传人员名单" }}
            <!--                        accept=".xls, .xlsx, .xlsm, .pdf, .PDF, .et, .txt, .doc, .docx"-->
            <input type="file" class="upload-img-file2" @change="uploadUserGF($event)" ref="multifile" />
          </el-button>
        </div>
      </div>
      <div class="form-window" v-if="info.id != 9 && info.id != 10 && info.id != 11 && info.id != 15">
        <div class="form-window-line"></div>
        <div class="form-window-txt">
          人员<span v-if="min_num > 1">(最低被保人{{ min_num }}位)</span>
        </div>
        <div class="form-window-btn">
          <el-button :disabled="user_edit" size="mini" class="com-btn" @click="addUser()">添加被保人
          </el-button>
          <el-button :disabled="user_edit" size="mini" class="com-btn" @click="daoModel()">导入人员清单
          </el-button>
          <a v-if="info.id != 12" :href="base_url + '/static/人员名单导入模板.xlsx'" style="margin-left: 10px">
            <el-button :disabled="user_edit" size="mini" class="com-btn">下载人员模板
            </el-button>
          </a>
          <a v-if="info.id == 12" :href="base_url + '/static/被保人名单导入模板.xlsx'" style="margin-left: 10px">
            <el-button :disabled="user_edit" size="mini" class="com-btn">下载人员模板
            </el-button>
          </a>
        </div>
      </div>

      <div class="form-form" v-if="info.id != 9 && info.id != 10 && info.id != 11 && info.id != 15">
        <el-table size="small" border :data="user" :header-cell-style="{
          'background-color': '#E1EBFE',
          color: '#5180F9',
        }">
          <el-table-column label="序号" type="index" width="60px"></el-table-column>

          <el-table-column label="类型" v-if="info.id == 12" width="200px">
            <template slot-scope="item">
              <el-select v-model="item.row.type" size="small" placeholder="请选择类型">
                <el-option v-for="item in tabs" :key="item.value" :label="item.name" :value="item.value">
                </el-option>
              </el-select>
            </template>
          </el-table-column>

          <el-table-column :label="'姓名' + (info.id == 12 ? '/单位名称' : '')">
            <template slot-scope="item">
              <el-input :disabled="user_edit" placeholder="请输入" v-model="item.row.name" size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column :label="'身份证号' + (info.id == 12 ? '/统一信用代码' : '')" width="200px">
            <template slot-scope="item">
              <el-input :disabled="user_edit" @blur="blurIdcard(item.$index)" placeholder="请输入"
                v-model="item.row.id_card" size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="手机号" v-if="info.id == 12" width="150px">
            <template slot-scope="item">
              <el-input :disabled="user_edit" @blur="blurIdcard(item.$index)" placeholder="请输入"
                v-model="item.row.contact_mobile" size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="保费">
            <span slot-scope="item">￥：{{ fanan ? fananprice(item.row) : 0 }}</span>
          </el-table-column>
          <el-table-column label="操作" width="100px">
            <template slot-scope="item">
              <el-button :disabled="user_edit" size="small" type="text" @click="deleteUser(item.$index)">删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="form-btn-box">
          <div style="margin-right: 80px; font-size: 18px; font-weight: bold; color: #ed0009">
            总保费：￥{{ Number(cost).toFixed(2) * user.length }}
          </div>
          <el-button size="small" @click="updateInfoItem(4)">修改</el-button>
          <el-button size="small" class="com-btn" @click="saveStorage(2)">保存
          </el-button>
        </div>
      </div>
      <!-- 标的信息 -->
      <div v-if="info.id == 12">
        <elementProfile :edit="elementProfile_edit" :optionsHyAddress="optionsHyAddress"
          :propsHyAddress="propsHyAddress" @saveStorage="saveStorage" @updateInfoItem="updateInfoItem"
          :riskinfo="riskinfo"></elementProfile>
      </div>
      <div class="form-window" v-if="info.id == 9">
        <div class="form-window-line"></div>
        <div class="form-window-txt">投保充电桩清单</div>
        <div class="form-window-btn">
          <el-button :disabled="stake_edit" size="mini" class="com-btn" @click="addcdzqd()">新增充电桩
          </el-button>
          <el-button :disabled="stake_edit" size="mini" class="com-btn" @click="daocdzModel()">导入充电桩清单
          </el-button>
          <a :href="base_url + 'static/充电桩清单导入模板.xlsx'" style="margin-left: 10px">
            <el-button :disabled="stake_edit" size="mini" class="com-btn">下载充电桩模板
            </el-button>
          </a>
        </div>
      </div>
      <div class="form-form" v-if="info.id == 9">
        <el-table size="small" border :data="stake" :header-cell-style="{
          'background-color': '#E1EBFE',
          color: '#5180F9',
        }">
          <el-table-column label="序号" type="index" width="60px"></el-table-column>
          <el-table-column label="编号(序列号、S/N)">
            <template slot-scope="item">
              <el-input :disabled="stake_edit" placeholder="请输入编号" v-model="item.row.no" size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="100px">
            <template slot-scope="item">
              <el-button :disabled="stake_edit" size="small" type="text" @click="deletecdzqd(item.$index)">删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <div style="
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-top: 20px;
          ">
          <div style="font-size: 22px; color: #f86768">
            保费合计：¥{{ cdzPrice ? cdzPrice : "0" }}
          </div>
          <div>
            <el-button size="small" @click="updateInfoItem(15)">修改</el-button>
            <el-button size="small" class="com-btn" @click="saveStorage(15)">保存
            </el-button>
          </div>
        </div>
      </div>

      <div class="form-window">
        <div class="form-window-line"></div>
        <div class="form-window-txt">发票信息</div>
      </div>
      <div class="form-form">
        <el-form :disabled="invoice.edit" label-position="left" label-width="140px" size="small">
          <el-form-item label="发票类型">
            <el-select v-model="invoice.invoice_type">
              <el-option label="增值税专票" :value="1"></el-option>
              <el-option label="增值税普票" :value="2"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="发票抬头">
            <el-input placeholder="请输入发票抬头" v-model="invoice.invoice_name" class="form-input"></el-input>
          </el-form-item>
          <el-form-item label="纳税人编号">
            <el-input placeholder="请输入纳税人编号" v-model="invoice.invoice_no" class="form-input"></el-input>
          </el-form-item>

          <div v-if="invoice.invoice_type == 1">
            <el-form-item label="注册地址">
              <div class="form-address">
                <el-input placeholder="请输入详细地址" v-model="invoice.invoice_address" class="form-input"></el-input>
              </div>
            </el-form-item>
            <el-form-item label="注册电话">
              <el-input placeholder="请输入注册电话" v-model="invoice.invoice_mobile" class="form-input"></el-input>
            </el-form-item>
            <el-form-item label="开户银行">
              <el-input placeholder="请输入开户银行" v-model="invoice.invoice_bank" class="form-input"></el-input>
            </el-form-item>
            <el-form-item label="开户账户">
              <el-input placeholder="请输入开户账户" v-model="invoice.invoice_bank_no" class="form-input"></el-input>
            </el-form-item>
            <el-form-item label="收件人" v-show="info.type == 2">
              <el-input placeholder="请输入收件人" v-model="invoice.name" class="form-input"></el-input>
            </el-form-item>
            <el-form-item label="收件人手机号" v-show="info.type == 2">
              <el-input placeholder="请输入收件人手机号" v-model="invoice.mobile" class="form-input"></el-input>
            </el-form-item>
            <el-form-item label="收件地址" v-show="info.type == 2">
              <div class="form-address">
                <el-input placeholder="请输入详细地址" v-model="invoice.address" class="form-input"></el-input>
              </div>
            </el-form-item>
          </div>
          <div style="color: red" v-show="info.type == 1">
            数电票：在保险人开具好数电专票后，您可以在我的订单内，查看详情下载该保单对应的数电专票，下载时间以保险人实际开具时间为准。
          </div>
          <div v-show="info.type == 2">
            增值税专用发票说明： <br />1、季度单为全额增值税专用发票；<br />
            2、年单增值税专用发票部分为保费总额的40%，其余为医疗健康险的0税率普通发票。
          </div>
        </el-form>
        <div class="form-btn-box">
          <el-button size="small" @click="updateInfoItem(5)">修改</el-button>
          <el-button size="small" class="com-btn" @click="saveStorage(3)">保存
          </el-button>
        </div>
      </div>

      <div class="form-submit-btn">
        <!-- <div style="margin-bottom: 20px;font-size: 18px;color:#F00505;font-weight: bold">保费合计：</div> -->
        <el-button size="small" class="com-btn" @click="openDialog()">同意投保
        </el-button>
      </div>
    </div>

    <el-dialog :visible.sync="dao_model" title="导入人员清单" width="500px" :append-to-body="true"
      :close-on-click-modal="false">
      <el-upload :on-success="upSuccess" class="upload-demo" drag :action="info.id == 12 ? '/seller/upload/uploadProtected' : '/seller/upload/uploadUser'
        " multiple>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">只能上传xlsx/xls文件，且不超过500kb</div>
      </el-upload>
    </el-dialog>
    <el-dialog :visible.sync="dao_cdzModel" title="导入充电桩清单" width="500px" :append-to-body="true"
      :close-on-click-modal="false">
      <el-upload :on-success="upCdzSuccess" class="upload-demo" drag action="/seller/upload/uploadCdz" multiple>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">只能上传xlsx/xls文件，且不超过500kb</div>
      </el-upload>
    </el-dialog>
    <el-dialog :visible.sync="his_model" title="历史信息" width="600px" :close-on-click-modal="false"
      :destroy-on-close="true">
      <el-form ref="form" label-width="80px" :inline="true">
        <el-form-item label="企业名称">
          <el-input v-model="clientName" placeholder="请输入企业名称查询" size="mini"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button class="com-btn" size="mini" @click="getHistory()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table size="mini" border :data="his_list">
        <el-table-column type="index" width="60px"></el-table-column>
        <el-table-column label="企业名称" prop="insure.name"></el-table-column>
        <el-table-column label="统一信用编码" prop="insure.client"></el-table-column>
        <el-table-column label="操作" width="100px">
          <template slot-scope="item">
            <el-button size="mini" type="text" @click="seletcHis(item.row)">选择
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog :visible.sync="his_dialog" title="历史信息" width="600px" :append-to-body="true"
      :close-on-click-modal="false">
      <el-form ref="form" label-width="80px" :inline="true">
        <el-form-item label="企业名称">
          <el-input v-model="clientName" placeholder="请输入企业名称查询" size="mini"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button class="com-btn" size="mini" @click="getClient">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table size="mini" border :data="clientList" key="his_dialog">
        <el-table-column type="index" width="60px"></el-table-column>
        <el-table-column label="企业名称" prop="name"></el-table-column>
        <el-table-column label="统一信用编码" prop="client"></el-table-column>
        <el-table-column label="操作" width="100px">
          <template slot-scope="item">
            <el-button size="mini" type="text" @click="seletcHisArr(item.row)">选择
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <div id="divplay"></div>
    <div>
      <!-- 投保须知弹窗 -->
      <el-dialog :visible.sync="dialogVisible" show-close class="xz">
        <template #title>
          <div style="
              width: 100%;
              height: 50px;
              position: relative;
              display: flex;
              justify-content: center;
              align-items: center;
              background-color: #f5f5f5;
            ">
            <div class="text-[16px]" style="font-size: 16px">投保须知</div>
            <div @click="router.push('/index/home')" style="
                width: 12px;
                height: 12px;
                position: absolute;
                top: 16px;
                right: 30px;
                cursor: pointer;
              " class="w-[12px] h-[12px] absolute top-[16px] right-[30px] cursor-pointer">
              <!-- <el-image
                :src="getAssetsFile('home/close.png')"
                class="w-full h-full"
              ></el-image> -->
            </div>
          </div>
        </template>
        <div style="padding: 0 20px">
          <div>
            <div style="font-weight: bold; font-size: 20px; margin-bottom: 20px">
              投保须知
            </div>
            <div class="p-[30px]" v-html="tkInfo.notice ? tkInfo.notice : ''"></div>
          </div>
          <div>
            <div style="
                font-weight: bold;
                font-size: 20px;
                margin-bottom: 20px;
                margin-top: 20px;
              ">
              客户通知书
            </div>
            <div class="p-[30px]" v-html="tkInfo.inform ? tkInfo.inform : ''"></div>
          </div>
          <div>
            <div style="
                font-weight: bold;
                font-size: 20px;
                margin-bottom: 20px;
                margin-top: 20px;
              ">
              特别约定
            </div>
            <div v-for="t in tkInfo.contributing" :key="t.id" class="p-[30px]">
              <div style="font-weight: bold;">
                方案：{{ t.name }}
              </div>
              <div v-html="t.content ? t.content : ''"></div>
            </div>

          </div>
          <!-- <div v-else>
            <div style="
                font-weight: bold;
                font-size: 20px;
                margin-bottom: 20px;
                margin-top: 20px;
              ">
              特别约定
            </div>
            <div class="p-[30px]" v-html="tkInfo.contributing ? tkInfo.contributing : ''"></div>
          </div> -->

          <div>
            <div style="
                font-weight: bold;
                margin-top: 20px;
                font-size: 20px;
                margin-bottom: 20px;
              ">
              保险条款
            </div>
            <div class="form-rich-tiao" v-for="(item, key) in tkInfo.list" :key="key" @click="toclause(item.id)">
              {{ item.title }}
            </div>
          </div>

          <div class="form-rich">
            <div class="form-rich-head">投保人声明</div>
            <div class="form-rich-warning">
              <!-- <img src="https://jy-yyzj.oss-cn-shanghai.aliyuncs.com/jdbx/pc/form-warning.png"
                class="form-rich-warning-icon" /> -->
              <div class="form-rich-warning-txt">
                为充分保障您的权益，请您仔细阅读后勾选确认
              </div>
            </div>
            <div class="form-rich-body">
              <div class="form-rich-shen">
                <img @click="changeAgree1()" v-if="agree1" src="@/assets/img/form-shen.png"
                  class="form-rich-warning-icon" />
                <div @click="changeAgree1()" class="form-rich-shen-no" v-else></div>
                <div class="form-rich-shen-msg">
                  本人已完整阅读并了解以上投保须知及投保险种的保险条款，尤其是对其中免除保险人责任的条款或约定（包括但不限于责任免除、投保人被保险人义务、保险金申请与给付等），本人已充分理解并接受上述内容，同意以此作为订立保险合同的依据
                </div>
              </div>
              <div class="form-rich-shen" style="margin-top: 5px">
                <img @click="changeAgree2()" v-if="agree2" src="@/assets/img/form-shen.png"
                  class="form-rich-warning-icon" />
                <div @click="changeAgree2()" class="form-rich-shen-no" v-else></div>
                <div class="form-rich-shen-msg">
                  投保时，投保人已就该产品的保障内容以及保险金额等向被保险人进行了明确说明，并征得其同意
                </div>
              </div>
            </div>
          </div>
        </div>
        <div>
          <div style="
              width: 100%;
              height: 130px;
              box-shadow: 0px -3px 8px 0px rgba(209, 209, 209, 0.25);
              border-radius: 0px 0px 10px 10px;
              display: flex;
              align-items: center;
              justify-content: center;
              flex-direction: column;
              margin-top: 30px;
            ">
            <div class="mt-[30px]">
              <el-button @click="submit" :dark="true" class="w-[240px]" size="large"
                :disabled="dialogTime ? true : false"><span class="text-white">我已全部阅读</span>
                <span v-if="dialogTime">{{ dialogTime }}</span>
              </el-button>
            </div>
          </div>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import step from "../../components/step/step.vue";
import province from "../../assets/js/province";
import city from "../../assets/js/city";
import area from "../../assets/js/area";
import upload from "../../components/upload/sm-upload.vue";
import upload2 from "../../components/upload/sm-uploadC.vue";
import insureProfile from "./insure/insureProfile.vue";
import insuredProfile from "./insure/insuredProfile.vue";
import yunProfile from "./insure/yunProfile.vue";
import goodsProfile from "./insure/goodsProfile.vue";
import insuredBus from "./insure/insuredBus.vue";
import businessPlace from "./insure/businessPlace.vue";
import elementProfile from "./insure/element.vue";
import * as rrweb from "rrweb";
// import rrwebPlayer from "rrweb-player";
import "rrweb-player/dist/style.css";

var arrList = [];
export default {
  components: {
    step,
    upload,
    insureProfile,
    insuredProfile,
    yunProfile,
    goodsProfile,
    upload2,
    insuredBus,
    businessPlace,
    elementProfile,
  },
  data() {
    return {
      ccbe_arr: [{
        name: '5000',
        price: 50
      }, {
        name: '8000',
        price: 80
      }],
      level_id: "",
      level_name: "",
      tbTimearr: ["三个月", "六个月", "一年"],
      timeName: "",
      timeIndex: "",
      djItem: {},
      cardType: "身份证",
      tabs: [
        {
          name: "企业",
          isActive: true,
          value: 1,
        },
        {
          name: "个人",
          isActive: false,
          value: 2,
        },
      ],
      wg_name: "",
      ylfy_name: "",
      flfy_name: "",
      zyjt_name: "",
      gzzrx_name: "",
      finishedPrice: "", //附加完工责任价格
      firePrice: "", //附加火灾爆炸价格
      hoursPrice: "", //附加24小时价格
      thirdPrice: "", //附加三者价格
      robPrice: "", //附加盗抢价格
      cost: "", //保费
      agree3: false,
      dialogTime: 10,
      dialogVisible: false,
      tkInfo: {},
      Third: false,
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now();
          // return time.getTime() < 1683276108000;
        },
      },
      info: {
        is_show: 0,
      },
      id: 0,
      fanan: "",
      fananIndex: 0,
      level: "",
      levelIndex: 0,
      dtLevelIndex: 0,
      edit: false,
      is_third: 0,
      is_fire: 0,
      is_open: true,
      open_name: "",
      open_no: "",
      open_arr: [],
      insure: {
        edit: false,
        name: "",
        client: "",
        province: "",
        city: "",
        area: "",
        // 回显地址拼写
        modelPGR: "",
        address: "",
        contact: "",
        contact_mobile: "",
        is_manage: true,
        license: "",
        type: 1, //1是企业，2是个人
      },
      invoice: {
        edit: false,
        invoice_type: 2,
        invoice_name: "",
        invoice_no: "",
        invoice_mobile: "",
        invoice_bank: "",
        invoice_bank_no: "",
        invoice_province: "",
        invoice_city: "",
        invoice_area: "",
        invoice_address: "",
        name: "",
        mobile: "",
        province: "",
        city: "",
        area: "",
        address: "",
      },
      user: [],
      stake: [],
      user_edit: false,
      stake_edit: false,
      edit_other: false,
      insureProfile_edit: false,
      insuredProfile_edit: false,
      yunProfile_edit: false,
      goodsProfile_edit: false,
      insuredBus_edit: false,
      businessPlace_edit: false,
      elementProfile_edit: false,
      cdzProfile_edit: false,
      pro_index: 0,
      city_index: 0,
      area_index: 0,
      insure_pro: [],
      insure_city: [],
      insure_area: [],
      now_time: "",
      start_time: "",
      end_time: "",
      i_p_index: 0,
      i_c_index: 0,
      i_a_index: 0,
      i_pro: [],
      i_city: [],
      i_area: [],
      i_ps_index: 0,
      i_cs_index: 0,
      i_as_index: 0,
      i_pros: [],
      i_citys: [],
      i_areas: [],
      rich1: "",
      rich2: "",
      agree1: false,
      agree2: false,
      time_eidt: false,
      order_id: 0,
      is_add: false,
      dao_model: false,
      dao_cdzModel: false,
      his_list: [],
      his_model: false,
      his_dialog: false,
      clauseList: [],
      loading: false,
      is_four: 0,
      is_rob: 0,
      is_finished: false,
      clientList: [],
      key: 0,
      clientName: "",
      chooseDta: {},
      propsAddress: {
        emitPath: true,
        lazy: true,
        value: "label",
        lazyLoad: (node, resolve) => {
          if (node.level == 0) {
            this.getAddress();
          }
          if (node.level == 1) {
            this.getCity(node, resolve);
          } else if (node.level == 2) {
            node.level = 2;
            this.getArea(node, resolve);
          }
        },
      },
      //国寿货运险的省市区
      propsHyAddress: {
        emitPath: true,
        lazy: true,
        value: "label",
        lazyLoad: (node, resolve) => {
          if (node.level == 0) {
            this.getAddress();
          }
          if (node.level == 1) {
            this.getCity(node, resolve);
          } else if (node.level == 2) {
            node.level = 2;
            this.getArea(node, resolve);
          }
        },
      },
      optionsAddress: [],
      optionsHyAddress: [],
      stopFun: () => { },
      cdzPrice: "",
      charge_info: {
        edit: false,
        name: "",
        client: "",
        province: "",
        city: "",
        area: "",
        // 回显地址拼写
        modelPGR: "",
        address: "",
        contact: "",
        contact_mobile: "",
        is_manage: true,
        license: "",
        area_num: "",
        num: "",
        number: ""
      },
      uploadUserLoading: false,
      key_from: {
        // 营业执照  上传key ：license_key
        license_key: "",
        // 人员名单上传key ：personnel_key
        personnel_key: "",
      },
      min_num: 0,
      // 货物保险的提交数据
      hyParam: {
        insure: {
          type: 1,
          name: "",
          email: "caiqingwen1976@163.com",
          client: "",
          province: "",
          city: "",
          area: "",
          address: "",
          contact: "",
          contact_mobile: "",
          license: '',
        },
        insured: {
          type: 1,
          name: "",
          email: "caiqingwen1976@163.com",
          card_no: "",
          province: "",
          city: "",
          area: "",
          address: "",
          contact: "",
          contact_mobile: "",
          license: ''
        },
        goods: [
          {
            name: "",
            way: "",
            way_code: "",
          },
        ],
        transport: {
          voyage_no: "",
          vehicle_name: "",
          toncount: "",
          departure_province: "",
          departure_city: "",
          departure_area: "",
          departure_station: "",
          terminal_province: "",
          terminal_city: "",
          terminal_area: "",
          terminal_station: "",
          shipment_date: "",
        },
      },
      //商户保
      shParam: {
        //营业场所信息
        premises: {
          no: "",
          province: "",
          city: "",
          area: "",
          address: "",
          area_num: "",
          structure: "",
          nature: "",
        },
        merchant: {
          name: "",
          merchant: "",
        },
      },
      // 平安年安光伏物损三者险的标的要素字段
      riskinfo: {
        structure_code: "",
        structure_name: "",
        province: "",
        city: "",
        area: "",
        address: "",
      },
      plan_id: "",
      time_type: "", //1是一年 6是半年
      property_type: '5000',
      ccbe_price: 50,
      insured_check: '',
      fananText: '保障方案',
    };
  },
  computed: {},
  mounted() {
    this.id = this.$route.params.id;
    this.order_id = this.$route.query.order_id;
    if (this.$route.query.is_add) {
      this.is_add = true;
    }
    if (this.showTestFeatures) {
      if (this.id == 15) {
        this.fananText = '责任限额'
      } else {
        this.fananText = '保障方案'
      }
    }

    this.getData();
    this.insureAddr();
    this.invoceIAddr();
    this.invoceIAddrs();
    this.getNowTime();
    // this.getRich1();
    // this.getRich2();

    // this.getClause();
    this.getClient();
    setInterval(() => {
      this.getNowTime();
    }, 1000);

    this.player();
  },

  beforeRouteLeave(to, from, next) {
    this.stopFun();
    arrList = [];
    next();
  },
  methods: {
    //投保人切换类型
    insureClickTabs() {
      if (this.showTestFeatures && this.insured_check) {
        this.hyParam.insured = JSON.parse(JSON.stringify(this.hyParam.insure));
        this.hyParam.insured.card_no = JSON.parse(JSON.stringify(this.hyParam.insure.client));
      }
    },
    //充电桩方案
    selectCdj(item, index) {
      this.djItem = item;
      this.min_num = item.min_num;
      this.level_name = item.name;
      this.levelIndex = index;
      this.level_id = item.id;


      this.chooseDta = this.info.level[index];
      this.plan_id = this.chooseDta.plan[this.fananIndex].id
      console.log(this.plan_id, '保障方案的plan_id');
      console.log(this.level_id, '保障方案的level_id');
      if (this.fanan) {
        console.log('充电桩方案');
        this.countCost1();
      }
      this.selectStartTime();
      this.$forceUpdate();
    },
    //切换企业和个人
    clickTabs(index) {
      this.tabs.forEach((item, i) => {
        if (i == index) {
          item.isActive = true;
        } else {
          item.isActive = false;
        }
      });

      if (index == 0) {
        this.insure.type = 1;
      } else {
        this.insure.type = 2;
      }
    },
    //同被保人
    clickCheck(checked) {

      // 用Promise封装
      return new Promise((resolve) => {
        console.log(checked);
        if (this.showTestFeatures) {
          if (checked) {
            this.hyParam.insured = JSON.parse(JSON.stringify(this.hyParam.insure));
            this.hyParam.insured.card_no = JSON.parse(JSON.stringify(this.hyParam.insure.client));
            console.log('测试环境');
          } else {
            for (let i in this.hyParam.insured) {
              this.hyParam.insured[i] = '';
            }
            this.hyParam.insured.type = 1;
            this.hyParam.insured.email = 'caiqingwen1976@163.com'
            this.hyParam.insured.card_no = ''
          }
          this.insured_check = checked;
          resolve('测试环境处理完成');
        } else {
          this.hyParam.insured = JSON.parse(JSON.stringify(this.hyParam.insure));
          this.hyParam.insured.card_no = JSON.parse(JSON.stringify(this.hyParam.insure.client));
          console.log('正式环境');
          resolve('正式环境处理完成');
        }
      }).then((msg) => {
        // 可以根据需要在这里处理后续逻辑
        console.log(msg);
      }).catch((err) => {
        // 错误处理
        console.error(err);
      });



    },
    //上传人员名单
    uploadUserGF(e) {
      var file = e.currentTarget.files;
      //优化上传的文件格式
      const reg = /(\.xls|\.xlsx|\.xlsm|\.pdf|\.PDF|\.et|\.txt|\.docx|\.doc|\.jpg|\.jpeg|\.JPG|\.JPEG|\.PNG|\.png)$/g;
      if (!reg.test(file[0].name)) {
        return this.$message("请上传正确的文件格式");
      }
      if (file[0] == undefined) return false;
      this.uploadUserLoading = true;
      this.fileUploadGF2(file[0]);
    },
    fileUploadGF2(img) {
      this.ajaxs("order/getFiledKey", {
        data: {},
        success: (res) => {
          if (res.code) {
            let data = res.msg;
            const formData = new FormData();
            formData.append("token", data.token);
            formData.append("file", img, img.name);
            const config = {
              headers: {
                "Content-Type": "multipart/form-data",
              },
            };
            // let url = "https://stg-iobs-upload.pingan.com.cn/upload/"+ data.bucket+'/' +data.key
            this.ajaxsC(data.url, {
              data: formData,
              headers: config,
              success: (res) => {
                if (res.key) {
                  this.key_from.personnel_key = res.key;
                  this.toast(1, "上传成功");
                  this.uploadUserLoading = false;
                } else {
                  this.uploadUserLoading = false;
                  this.toast(0, "上传失败");
                }
              },
            });
          } else {
            this.uploadUserLoading = false;
            this.toast(res.msg);
          }
        },
      });
    },
    //财产保额
    selectCcbe(index, item) {
      if (this.showTestFeatures) {
        this.property_type = item.name;
        this.ccbe_price = item.price;

        this.$forceUpdate();
        this.countCost1();
        if (this.info.id == 9 || this.info.id == 15) {
          if (this.showTestFeatures) {
            this.cdzPrice = Number(this.cost)
            console.log(this.cost);

          } else {
            this.cdzPrice = Number(this.cost) * this.stake.length;
          }

        }
      }

    },
    //获取缓存方案
    getLevel() {
      this.info.level.forEach((item, i) => {
        if (item.id == this.level_id) {
          console.log('获取缓存方案');

          this.levelIndex = i;
        }
        item.plan.forEach((t, j) => {
          if (t.name == this.fanan) {
            this.fananIndex = j;
          }
        });
      });
      // this.info.dt_level.forEach((tj) => {
      //   tj.level.forEach((item, i) => {
      //     if (item.name == this.level) {
      //       this.levelIndex = i;
      //     }
      //     item.plan.forEach((t, j) => {
      //       if (t.name == this.fanan) {
      //         this.fananIndex = j;
      //       }
      //     });
      //   });
      // });

      this.wg_name = this.info.level[this.levelIndex].plan[this.fananIndex].wg_name;
      this.flfy_name = this.info.level[this.levelIndex].plan[this.fananIndex].flfy_name;
      this.ylfy_name = this.info.level[this.levelIndex].plan[this.fananIndex].ylfy_name;
      this.zyjt_name = this.info.level[this.levelIndex].plan[this.fananIndex].zyjt_name;
      this.gzzrx_name = this.info.level[this.levelIndex].plan[this.fananIndex].gzzrx_name;
      // if (!this.is_add) {
      //   //不是续保
      //   this.wg_name = this.info.level[this.levelIndex].plan[this.fananIndex].wg_name;
      //   this.flfy_name = this.info.level[this.levelIndex].plan[this.fananIndex].flfy_name;
      //   this.ylfy_name = this.info.level[this.levelIndex].plan[this.fananIndex].ylfy_name;
      //   this.zyjt_name = this.info.level[this.levelIndex].plan[this.fananIndex].zyjt_name;
      // } else {
      //   //续保
      //   this.wg_name = this.info.level[this.levelIndex].plan[this.fananIndex].wg_name;
      //   this.flfy_name = this.info.level[this.levelIndex].plan[this.fananIndex].flfy_name;
      //   this.ylfy_name = this.info.level[this.levelIndex].plan[this.fananIndex].ylfy_name;
      //   this.zyjt_name = this.info.level[this.levelIndex].plan[this.fananIndex].zyjt_name;
      //   this.gzzrx_name = this.info.level[this.levelIndex].plan[this.fananIndex].gzzrx_name;
      // }

      if (this.is_third) {
        if (this.info.level[this.levelIndex].plan[this.fananIndex].third_data) {
          this.thirdPrice = this.info.level[this.levelIndex].plan[
            this.fananIndex
          ].third_data.price;
        }
      } else {
        this.thirdPrice = 0;
      }

      if (this.is_four) {
        if (this.info.level[this.levelIndex].plan[this.fananIndex].finished_data) {
          this.finishedPrice = this.info.level[this.levelIndex].plan[
            this.fananIndex
          ].finished_data.price;
        }
      } else {
        this.finishedPrice = 0;
      }
      if (this.is_fire) {
        if (this.info.level[this.levelIndex].plan[this.fananIndex].fire_data) {
          this.firePrice = this.info.level[this.levelIndex].plan[
            this.fananIndex
          ].fire_data.price;
        }
      } else {
        this.firePrice = 0;
      }
      if (this.is_rob) {
        if (this.info.level[this.levelIndex].plan[this.fananIndex].rob_data) {
          this.robPrice = this.info.level[this.levelIndex].plan[
            this.fananIndex
          ].rob_data.price;
        }
      } else {
        this.robPrice = 0;
      }


    },
    //计算保费
    countCost1() {
      // this.getLevel();
      console.log('保费价格');
      console.log('this.ccbe_price:' + this.ccbe_price);

      console.log(this.info.level[this.levelIndex].plan[this.fananIndex].price);

      this.cost =
        Number(this.info.level[this.levelIndex].plan[this.fananIndex].price) +
        Number(this.hoursPrice) +
        Number(this.thirdPrice) +
        Number(this.finishedPrice) +
        Number(this.firePrice) +
        Number(this.robPrice) + Number(this.ccbe_price);


      // console.log(this.cost, this.finishedPrice);
    },
    //打卡弹窗
    openDialog() {
      // this.getTanChuan();
      if (this.info.id == 15 && this.property_type == '' && this.showTestFeatures) {
        return this.toast(0, "请选择财产保额");
      }
      if (!this.fanan) return this.toast(0, "请选择方案");
      if (this.info.id != 10 && this.info.id != 12 && this.info.id != 15) {
        if (!this.insure.name) return this.toast(0, "请输入企业名称");
        if (!this.insure.client) return this.toast(0, "请输入统一信用编码");
        if (!this.insure.contact && !this.showTestFeatures) return this.toast(0, "请输入法人");
        if (!this.insure.contact_mobile && !this.showTestFeatures) return this.toast(0, "请输入法人手机号");

        if (this.insure.contact_mobile.length != 11 && !this.showTestFeatures)
          return this.toast(0, "请输入正确的法人手机号");
        if (!this.insure.license && !this.showTestFeatures) return this.toast(0, "请上传营业执照");
        if (!this.insure.address && !this.showTestFeatures) return this.toast(0, "请完善地址");
      }
      if (this.info.id == 12) {
        for (let i in this.riskinfo) {
          if (this.riskinfo[i] == "") return this.toast(0, "标的要素信息未填写完整");
        }
      }
      if (!this.start_time && this.info.id != 10) return this.toast(0, "请选择生效时间");

      if (this.info.id != 9 && this.info.id != 10 && this.info.id != 11 && this.info.id != 15) {
        if (this.user.length == 0) return this.toast(0, "请添加被保人员");
      }
      if (this.info.id == 9) {
        if (this.stake.length == 0) return this.toast(0, "请添加充电桩清单");
      }
      for (var i in this.user) {
        if (!this.user[i].name) return this.toast(0, "请输入被保人员姓名");
        if (!this.user[i].id_card) return this.toast(0, "请输入被保人员身份证");
      }
      if (this.info.id == 9 || this.info.id == 15) {
        for (var j in this.stake) {
          if (!this.stake[j].no) return this.toast(0, "请输入清单编号");
          // if (!this.stake[j].price) return this.toast(0, "请输入清单价值");
        }
      }
      if (!this.invoice.invoice_name) return this.toast(0, "请输入发票抬头");
      if (!this.invoice.invoice_no) return this.toast(0, "请输入纳税人编号");
      if (this.min_num > 1) {
        if (this.user.length < this.min_num) {
          return this.toast(0, "请添加最低" + this.min_num + "位被保人员");
        }
      }
      if (this.invoice.invoice_type == 1) {
        if (!this.invoice.invoice_mobile) return this.toast(0, "请输入注册电话");
        if (!this.invoice.invoice_bank) return this.toast(0, "请输入开户银行");
        if (!this.invoice.invoice_bank_no) return this.toast(0, "请输入开户账户");

        // if (!this.invoice.name) return this.toast(0, "请输入收件人");
        // if (!this.invoice.mobile) return this.toast(0, "请输入收件人手机号");
        // if (!this.invoice.address) return this.toast(0, "请完善地址");

        /*if (
                  !this.invoice.address ||
                  !this.invoice.province ||
                  !this.invoice.city ||
                  !this.invoice.area
                )
                  return this.toast(0, "请完善地址");*/
      }
      /*if(this.is_open && !this.open_name)return this.toast(0,'请输入被保企业名称');
            if(this.is_open && !this.open_no)return this.toast(0,'请输入被保企业统一信用编码');*/
      /*if(this.is_open) {
              var open_name_arr = this.open_name.split('、');
              var open_no_arr = this.open_no.split('、');
              if(open_name_arr.length != open_no_arr.length)return this.toast(0,'请完善被保企业名称或统一信用编码');
            }*/
      for (var x in this.open_arr) {
        if (!this.open_arr[x].name) return this.toast(0, "请输入企业名称");
        if (!this.open_arr[x].client) return this.toast(0, "请输入统一信用编码");
      }
      this.getTanChuan();
    },
    //倒计时
    countDown() {
      let t = setInterval(() => {
        if (this.dialogTime <= 0) {
          clearInterval(t);
          return;
        }
        this.dialogTime--;
      }, 1000);
    },
    //获取投保须知弹窗数据
    getTanChuan() {
      this.ajaxs("index/getInsureContent", {
        data: {
          id: this.id,
          third: this.Third,
          finished: this.is_finished,
          is_fire: this.is_fire,
          is_rob: this.is_rob,
        },
        success: (res) => {
          if (res.code == 1) {
            this.tkInfo = res.msg;
            this.dialogVisible = true;
            this.countDown();
          }
          //console.log(res);
        },
      });
    },
    //录制视频
    player() {
      console.log(arrList);
      this.stopFun = rrweb.record({
        emit(event) {
          arrList.push(event);
        },
      });
    },
    // bf() {
    //   this.stopFun();
    //   console.log(JSON.stringify(arrList));
    //   new rrwebPlayer({
    //     target: document.getElementById("divplay"),
    //     props: { events: arrList },
    //   });
    // },
    getAddress() {
      let data = {};
      if (this.info.id == 15) {
        data = {
          type: 1,
          special: 1,
        };
      }
      this.ajaxs("index/getProvince", {
        data: data,
        success: (res) => {
          this.optionsAddress = res.msg;
          if (this.info.id == 10 || this.info.id == 12 || this.info.id == 15) {
            this.optionsHyAddress = res.msg;
          }
        },
      });
    },
    getCity(node, resolve) {
      let data = { code: node.data.value };
      if (this.info.id == 15) {
        data = {
          type: 1,
          code: node.data.value,
          special: 1
        };
      }
      this.ajaxs("index/getCity", {
        data: data,
        success: (res) => {
          let optionChild = res.msg;
          optionChild.map((item) => {
            return {
              value: item.value,
              label: item.label,
            };
          });
          resolve(optionChild);
        },
      });
    },
    getArea(node, resolve) {
      console.log(node);

      let data = { code: node.data.value };
      if (this.info.id == 15) {
        data = {
          type: 1,
          code: node.data.value,
          special: 1
        };
      }
      this.ajaxs("index/getArea", {
        data: data,
        success: (res) => {
          let optionChilds = res.msg;
          optionChilds.map((item) => {
            item.leaf = true; // 这里是区分最后一级时不让显示箭头
            return {
              value: item.value,
              label: item.label,
              children: [],
            };
          });
          resolve(optionChilds);
        },
      });
    },

    changeAddress(e) {
      this.insure.province = e[0];
      this.insure.city = e[1];
      this.insure.area = e[2];
      this.insure.modelPGR = e[0] + "/" + e[1] + "/" + e[2];
    },
    changecdzAddress(e) {
      this.charge_info.province = e[0];
      this.charge_info.city = e[1];
      this.charge_info.area = e[2];
      this.charge_info.modelPGR = e[0] + "/" + e[1] + "/" + e[2];
    },
    editOpenArr(key) {
      this.key = key;
      this.his_dialog = true;
      this.clientName = "";
    },
    deleteOpenArr(index) {
      this.open_arr.splice(index, 1);
    },
    addBei() {
      this.open_arr.push({
        name: "",
        client: "",
        address: "",
        contact: "",
        contact_mobile: "",
        license: "",
      });
    },
    fananprice(data) {
      // console.log(this.info.fanan[this.fanan].price);
      console.log(data);
      this.$forceUpdate();
      if (!this.fanan) return 0;
      this.countCost1();
      if (this.info.id == 9 || this.info.id == 15) {
        // this.countCost(
        //   this.info.fanan[this.fanan].price,
        //   this.info.fire[this.fanan].price,
        //   this.stake.length,
        //   this.is_fire
        // );
      }

      return this.cost;
    },
    seletcHis(data) {
      this.his_model = false;
      this.invoice = JSON.parse(JSON.stringify(data.invoice));
      this.key_from.license_key = JSON.parse(JSON.stringify(data.img_key));
      this.insure = JSON.parse(JSON.stringify(data.insure));
      this.insureAddr();
      this.invoceIAddr();
      this.invoceIAddrs();
    },
    seletcHisArr(data) {
      this.his_dialog = false;
      this.open_arr[this.key] = data;
    },
    getHistory() {
      this.ajaxs("index/getClient", {
        data: { name: this.clientName, type: this.info.type },
        success: (res) => {
          this.his_list = res.msg;
        },
      });
    },

    getClient() {
      this.ajaxs("index/getClientList", {
        data: { name: this.clientName },
        success: (res) => {
          this.clientList = res.msg;
        },
      });
    },
    history() {
      this.his_model = true;
      this.clientName = "";
    },
    upSuccess(e) {
      console.log(e);
      if (e.code == 0) {
        this.toast(0, e.msg);
        this.dao_model = false;
        return;
      }
      // this.user = this.user.concat(e.msg);

      for (var x in e.msg) {
        var allow = true;
        for (var i in this.user) {
          if (e.msg[x].id_card == this.user[i].id_card) allow = false;
        }
        if (allow == true) this.user.push(e.msg[x]);
      }

      this.dao_model = false;
    },
    upCdzSuccess(e) {
      if (e.code == 0) {
        this.toast(0, e.msg);
        this.dao_cdzmodel = false;
        return;
      }
      // this.user = this.user.concat(e.msg);
      for (var x in e.msg) {
        var allow = true;
        for (var i in this.stake) {
          if (e.msg[x].no == this.stake[i].no) allow = false;
        }
        if (allow == true) this.stake.push(e.msg[x]);
      }
      if (this.info.id == 9 || this.info.id == 15) {
        this.charge_info.num = this.stake.length;
        // this.countCost(
        //   this.info.fanan[this.fanan].price,
        //   this.info.fire[this.fanan].price,
        //   this.stake.length,
        //   this.is_fire
        // );
      }

      this.dao_cdzModel = false;
    },
    daoModel() {
      this.dao_model = true;
    },
    daocdzModel() {
      this.dao_cdzModel = true;
    },
    todoc(type) {
      let routeData = this.$router.resolve({
        path: "/index/index/doc/" + type,
      });
      window.open(routeData.href, "_blank");
    },
    toclause(id) {
      let routeData = this.$router.resolve({
        path: "/index/index/clause/" + id,
      });
      window.open(routeData.href, "_blank");
    },
    blurIdcard(index) {
      if (this.user[index].id_card.length != 18) {
        this.user[index].id_card = "";
        return this.toast(
          0,
          "请输入正确的" + this.user[index].type == 1 ? "统一信用代码" : "身份证"
        );
      }
      for (var i in this.user) {
        if (i != index && this.user[i].id_card == this.user[index].id_card) {
          this.user[index].id_card = "";
          return this.toast(0, "被保人已存在");
        }
      }
    },
    qiyeName() {
      if (this.showTestFeatures && this.info.id == 15) {
        this.invoice.invoice_name = this.hyParam.insure.name;
       
        this.$forceUpdate();
        return
      }
      this.invoice.invoice_name = this.insure.name;
    },
    qiyeNo() {
      if (this.showTestFeatures && this.info.id == 15) {
        this.invoice.invoice_no = this.hyParam.insure.client;
        this.$forceUpdate();
        return
      }
      this.invoice.invoice_no = this.insure.client;
    },
    //提交保存
    async submit() {
      if (!this.agree1 || !this.agree2) return this.toast(0, "请先全部阅读并同意投保");
      await this.clickCheck(true);
      var data = this.createData();



      if (this.info.id == 10) {
        data.start_time = data.transport.shipment_date;
      }

      if (this.order_id && !this.is_add) data.id = this.order_id;
      this.loading = true;
      this.stopFun();
      this.ajaxs("order/addOrder", {
        data: data,
        success: (res) => {
          this.loading = false;
          if (res.code) {
            this.toast(1, "提交成功");
            this.$router.replace({
              path: "/index/index/confirm/" + res.msg,
            });
          } else {
            this.toast(res.code, res.msg);
          }
        },
      });
    },
    //修改信息
    updateInfoItem(type) {
      switch (type) {
        case 1:
          this.edit = false;
          break;
        case 2:
          this.insure.edit = false;
          this.user_edit = false;
          break;
        case 3:
          this.time_eidt = false;
          break;
        case 4:
          this.user_edit = false;
          break;
        case 5:
          this.invoice.edit = false;
          break;
        case 6:
          this.edit_other = false;
          break;
        case 7:
          //投保人信息
          this.insureProfile_edit = false;
          break;
        case 8:
          //被保人信息
          this.insuredProfile_edit = false;
          break;
        case 9:
          //运输信息
          this.yunProfile_edit = false;
          break;
        case 10:
          //货物信息
          this.goodsProfile_edit = false;
          break;
        case 11:
          //被保企业
          this.insuredBus_edit = false;
          break;
        case 12:
          //营业场所信息
          this.businessPlace_edit = false;
          break;
        case 13:
          //标的要素的信息
          this.elementProfile_edit = false;
          break;
        case 14:
          //充电桩信息
          this.cdzProfile_edit = false;
          break;
        case 15:
          //投保充电桩清单

          this.stake_edit = false;
          break;

      }
    },
    //获取缓存数据
    getStorage() {
      this.ajaxs("order/getSave", {
        data: {
          bx_id: this.id,
        },
        success: (res) => {
          if (res.msg != false) {
            this.$confirm("发现未完成的订单，是否继续填写?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
            })
              .then(() => {
                this.toFormData(res.msg);
              })
              .catch(() => { });
          }
        },
      });
    },
    //填充表单数据
    toFormData(data) {
      console.log(data);
      this.timeName = data.timeName;
      // this.djItem = data.djItem;
      this.min_num = data.min_num;
      this.fanan = data.fanan;
      this.level_name = data.level;
      this.level_id = data.level_id;
      this.time_type = data.time_type;


      this.start_time = data.start_time;
      this.end_time = data.end_time;
      if(this.info.id == 15 && this.showTestFeatures){
        this.insure = data.hyParam.insure;
      }else{
        this.insure = data.insure;
      }
  
      // this.hyParam.insure = data.insure;
      // this.hyParam.insured = data.insured;
      // this.hyParam.goods = data.goods;
      // this.hyParam.transport = data.transport
      if (data.hyParam) {
        this.hyParam = data.hyParam;
      }
      if (data.shParam) {
        this.shParam = data.shParam;
      }
      this.invoice = data.invoice;
      this.user = data.user;
      this.stake = data.stake;
      this.edit = data.edit;
      this.user_edit = data.user_edit;
      this.time_eidt = data.time_eidt;
      this.insureProfile_edit = data.insureProfile_edit;
      this.stake_edit = data.stake_edit;
      this.insuredProfile_edit = data.insuredProfile_edit;
      this.insured_check = data.insured_check;
      this.yunProfile_edit = data.yunProfile_edit;
      this.goodsProfile_edit = data.goodsProfile_edit;
      this.insuredBus_edit = data.insuredBus_edit;
      this.businessPlace_edit = data.businessPlace_edit;
      this.elementProfile_edit = data.elementProfile_edit;
      this.cdzProfile_edit = data.cdzProfile_edit;
      this.is_third = data.is_third;
      this.is_fire = data.is_fire;
      this.Third = data.is_third === 1 && this.info.is_third == 1 ? true : false;
      this.is_finished = data.is_finished;
      this.is_four = data.is_finished ? 1 : 0;
      this.is_rob = data.is_rob ? 1 : 0;
      this.is_open = data.is_open;
      this.open_name = data.open_name;
      this.plan_id = data.plan_id;
      this.open_no = data.open_no;
      this.open_arr = data.open_arr ? data.open_arr : [];
      this.key_from.license_key = data.license_key;
      this.key_from.personnel_key = data.personnel_key;
      this.riskinfo = data.riskinfo;
      this.dtLevelIndex = data.dtLevelIndex;
      if (this.showTestFeatures) {
        this.property_type = data.property_type
        this.insured_check = data.insured_check
        this.ccbe_arr.forEach((t) => {
          if (t.name == this.property_type) {
            this.ccbe_price = t.price;
          }
        })
      }

      // this.hyParam = data.hyParam;
      this.insureAddr();

      this.invoceIAddr();

      this.invoceIAddrs();

      this.getLevel();
      // if (!this.order_id) {
      //   this.selectDjFanan(this.djItem, this.levelIndex);
      // }

      if (this.info.id == 9 || this.info.id == 15) {
        this.charge_info = data.charge_info;
        this.charge_info.num = this.stake.length;
        if (this.showTestFeatures) {
          this.cdzPrice = Number(this.cost)
        } else {
          this.cdzPrice = Number(this.cost) * this.stake.length;
        }

      }
      this.chooseDta.plan.forEach((item, i) => {
        if (item.name == this.fanan) {
          this.fananIndex = i;
        }
      });
      if (this.showTestFeatures) {
        this.insured_check = data.insured_check
      }

      this.countCost1();
    },
    //保存缓存数据
    saveStorage(type) {
      switch (type) {
        case 0:
          this.user_edit = true;
          this.invoice.edit = true;
          this.insure.edit = true;
          break;
        case 1:
          this.edit = true;
          break;
        case 2:
          this.user_edit = true;
          break;
        case 3:
          this.invoice.edit = true;
          break;
        case 4:
          this.insure.edit = true;
          break;
        case 5:
          this.time_eidt = true;
          break;
        case 6:
          this.edit_other = true;
          break;
        case 7:
          //投保人信息
          this.insureProfile_edit = true;
          break;
        case 8:
          //被保人信息
          this.insuredProfile_edit = true;
          break;
        case 9:
          //运输信息
          this.yunProfile_edit = true;
          break;
        case 10:
          //货物信息
          this.goodsProfile_edit = true;
          break;
        case 11:
          //被保企业信息
          this.insuredBus_edit = true;
          break;
        case 12:
          //营业场所信息
          this.businessPlace_edit = true;
          break;
        case 13:
          //标的要素信息
          this.elementProfile_edit = true;
          break;
        case 14:
          //充电桩信息
          this.cdzProfile_edit = true
          break
        case 15:
          //投保充电桩清单

          this.stake_edit = true
          break

        default:
          break;
      }
      // if (type == 0) {
      //   this.user_edit = true;
      //   this.invoice.edit = true;
      //   this.insure.edit = true;
      // }
      // if (type == 1) {
      //   this.edit = true;
      // }
      // if (type == 2) {
      //   this.user_edit = true;
      // }
      // if (type == 3) {
      //   this.invoice.edit = true;
      // }
      // if (type == 4) {
      //   this.insure.edit = true;
      // }
      // if (type == 5) {
      //   this.time_eidt = true;
      // }
      // if (type == 6) {
      //   this.edit_other = true;
      // }

      this.ajaxs("order/saveOrder", {
        data: this.createData(),
        success: (res) => {
          this.toast(res.code, res.msg);
          this.$forceUpdate();
        },
      });
    },
    //组装数据
    createData() {
      var data = {
        dtLevelIndex: this.dtLevelIndex,
        timeName: this.timeName,
        // djItem: this.djItem,
        bx_id: this.id,
        fanan: this.fanan,
        is_open: this.is_open,
        open_no: this.open_no,
        open_name: this.open_name,
        start_time: this.start_time,
        end_time: this.end_time,
        insure: this.info.id == 10 || this.info.id == 15 ? this.hyParam.insure : this.insure,
        insured: this.hyParam.insured,
        goods: this.hyParam.goods,
        transport: this.hyParam.transport,
        hyParam: this.hyParam,
        shParam: this.shParam,
        premises: this.shParam.premises,
        merchant: this.shParam.merchant,
        invoice: this.invoice,
        is_fire: this.is_fire,
        user: this.user,
        protected: this.user,
        stake: this.stake,
        charge_info: this.charge_info,
        edit: this.edit,
        user_edit: this.user_edit,
        time_eidt: this.time_eidt,
        insureProfile_edit: this.insureProfile_edit,
        stake_edit: this.stake_edit,
        insuredProfile_edit: this.insuredProfile_edit,
        insured_check: this.insured_check,
        yunProfile_edit: this.yunProfile_edit,
        goodsProfile_edit: this.goodsProfile_edit,
        insuredBus_edit: this.insuredBus_edit,
        businessPlace_edit: this.businessPlace_edit,
        elementProfile_edit: this.elementProfile_edit,
        cdzProfile_edit: this.cdzProfile_edit,
        is_third: this.is_third,
        open_arr: this.open_arr,
        is_finished: this.is_finished,
        is_rob: this.is_rob,
        level: this.level_name,
        level_id: this.level_id,
        time_type: this.time_type,
        mark: arrList,
        license_key: this.key_from.license_key,
        personnel_key: this.key_from.personnel_key,
        min_num: this.min_num,
        riskinfo: this.riskinfo,
        plan_id: this.plan_id,
        property_type: this.property_type,
      };


      return data;
    },
    changeAgree1() {
      this.agree1 = !this.agree1;
    },
    changeAgree2() {
      this.agree2 = !this.agree2;
    },
    //删除投保人
    deleteUser(index) {
      this.user.splice(index, 1);
    },
    //删除充电桩清单
    deletecdzqd(index) {
      this.stake.splice(index, 1);
      if (this.info.id == 9 || this.info.id == 15) {
        this.charge_info.num = this.stake.length;
        if (this.showTestFeatures) {
          this.cdzPrice = Number(this.cost)
        } else {
          this.cdzPrice = Number(this.cost) * this.stake.length;
        }

      }
    },
    //添加投保人
    addUser() {
      this.user.push({
        name: "",
        id_card: "",
      });
    },
    //添加充电桩清单
    addcdzqd() {
      let param = {
        no: "",
        price: "",
      };
      this.stake.push(param);
      console.log(this.stake);
      this.charge_info.num = this.stake.length;
      if (this.info.id == 9 || this.info.id == 15) {
        if (this.showTestFeatures) {
          this.cdzPrice = Number(this.cost)
        } else {
          this.cdzPrice = Number(this.cost) * this.stake.length;
        }

      }
    },
    //选择开始时间
    selectStartTime() {
      var d2 = new Date(this.start_time);
      if (this.info.id == 13) {
        if (this.time_type == 1) {
          d2.setFullYear(d2.getFullYear() + 1);
        }
        if (this.time_type == 6) {
          d2.setMonth(d2.getMonth() + 6);
          // if (this.level_name == "年度保险") {
          //   d2.setFullYear(d2.getFullYear() + 1);
          // } else {
          //   d2.setMonth(d2.getMonth() + 3);
          // }
        }
      } else {
        if (this.info.type == 1) {
          d2.setFullYear(d2.getFullYear() + 1);
        }
        if (this.info.type == 2) {
          if (this.level == "年度保险") {
            d2.setFullYear(d2.getFullYear() + 1);
          } else if (this.level == "月度保险") {
            d2.setMonth(d2.getMonth() + 1);
          } else if (this.level == "季度保险") {
            d2.setMonth(d2.getMonth() + 3);
          }
        }
      }


      var year = d2.getFullYear();
      var month = d2.getMonth() + 1;
      month = month < 10 ? "0" + month : month;
      var day = d2.getDate();
      day = day < 10 ? "0" + day : day;
      var date = year + "-" + month + "-" + day;
      if (this.info.id != 10) {
        this.end_time = date + " 00:00:00";
      }
    },
    //选择结束时间
    selectEndTime() { },
    getTargetTime(t) {
      var d = t.split(" ")[0],
        h = t.split(" ")[1],
        date = new Date();
      date.setYear(d.split("-")[0]);
      date.setMonth(d.split("-")[1] - 1);
      date.setDate(d.split("-")[2]);
      date.setHours(h.split(":")[0]);
      date.setMinutes(h.split(":")[1]);
      date.setSeconds(h.split(":")[2]);
      return date.getTime();
    },
    //获取时间
    getNowTime() {
      var date = new Date();
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      month = month > 10 ? month : "0" + month;
      var day = date.getDate();
      day = day > 10 ? day : "0" + day;
      var hour = date.getHours();
      hour = hour > 10 ? hour : "0" + hour;
      var minutes = date.getMinutes();
      minutes = minutes > 10 ? minutes : "0" + minutes;
      var second = date.getSeconds();
      second = second > 10 ? second : "0" + second;
      this.now_time =
        year + "-" + month + "-" + day + " " + hour + ":" + minutes + ":" + second;
    },
    //获取上传过后的key
    upLicenseKey(e) {
      this.key_from.license_key = e;
    },
    //上传图片
    upInsure(e, index, name) {
      console.log('上传图片');
      console.log(e, index);

      if (index == -1) {
        this.insure.license = e;

      } else {
        this.open_arr[index].license = e;
      }
      if (this.showTestFeatures && name == '投保') {
        this.hyParam.insure.license = e;
      }
      if (this.showTestFeatures && name == '被保') {
        this.hyParam.insured.license = e;
      }
      this.ajaxs("index/getFace", {
        data: {
          url: e,
        },
        success: (res) => {
          if (index == -1) {
            this.insure.name = res.msg.name;
            this.insure.address = res.msg.address;
            this.insure.client = res.msg.client;
            this.insure.contact = res.msg.legal_person;
            this.invoice.invoice_name = res.msg.name;
            this.invoice.invoice_no = res.msg.client;
            if (this.showTestFeatures && this.info.id == 15 && name == '投保') {

              this.hyParam.insure.name = res.msg.name;
              this.hyParam.insure.address = res.msg.address;
              this.hyParam.insure.client = res.msg.client;
              this.hyParam.insure.contact = res.msg.legal_person;

            }
            if (this.showTestFeatures && this.info.id == 15 && name == '被保') {


              this.hyParam.insured.name = res.msg.name;
              this.hyParam.insured.address = res.msg.address;
              this.hyParam.insured.client = res.msg.client;
              this.hyParam.insured.card_no = res.msg.client;

              this.hyParam.insured.contact = res.msg.legal_person;
            }
          } else {
            this.open_arr[index].name = res.msg.name;
            this.open_arr[index].address = res.msg.address;
            this.open_arr[index].client = res.msg.client;
            this.open_arr[index].contact = res.msg.legal_person;
            this.$forceUpdate();
          }
          console.log(this.insure);
        },
      });
    },
    changeInsureProvince() {
      this.city_index = 0;
      this.area_index = 0;
      this.insure.city = "";
      this.insure.area = "";
      this.insureAddr();
    },
    changeInvoceProvince() {
      this.i_c_index = 0;
      this.i_a_index = 0;
      this.invoice.invoice_city = "";
      this.invoice.invoice_area = "";
      this.invoceIAddr();
    },
    changeInvoceProvinces() {
      this.i_cs_index = 0;
      this.i_as_index = 0;
      this.invoice.city = "";
      this.invoice.area = "";
      this.invoceIAddrs();
    },
    changeInsureCity() {
      this.area_index = 0;
      this.insure.area = "";
      this.insureAddr();
    },
    changeInvoceCitys() {
      this.i_as_index = 0;
      this.invoice.area = "";
      this.invoceIAddrs();
    },
    changeInvoceCity() {
      this.i_a_index = 0;
      this.invoice.invoice_area = "";
      this.invoceIAddr();
    },
    invoceIAddr() {
      this.i_pro = province;
      for (var i in this.i_pro) {
        if (this.i_pro[i].label == this.invoice.invoice_province) {
          this.i_p_index = i;
        }
      }
      this.i_city = city[this.i_p_index];
      for (var x in this.i_city) {
        if (this.i_city[x].label == this.invoice.invoice_city) {
          this.i_c_index = x;
        }
      }
      this.i_area = area[this.i_p_index][this.i_c_index];
      for (var y in this.i_area) {
        if (this.i_area[y].label == this.invoice.invoice_area) {
          this.i_a_index = y;
        }
      }
    },
    invoceIAddrs() {
      this.i_pros = province;
      for (var i in this.i_pros) {
        if (this.i_pros[i].label == this.invoice.province) {
          this.i_ps_index = i;
        }
      }
      this.i_citys = city[this.i_ps_index];
      for (var x in this.i_citys) {
        if (this.i_citys[x].label == this.invoice.city) {
          this.i_cs_index = x;
        }
      }
      this.i_areas = area[this.i_ps_index][this.i_cs_index];
      for (var y in this.i_areas) {
        if (this.i_areas[y].label == this.invoice.area) {
          this.i_as_index = y;
        }
      }
    },
    //初始化地址
    insureAddr() {
      this.insure_pro = province;
      for (var i in this.insure_pro) {
        if (this.insure_pro[i].label == this.insure.province) {
          this.pro_index = i;
        }
      }
      this.insure_city = city[this.pro_index];
      for (var x in this.insure_city) {
        if (this.insure_city[x].label == this.insure.city) {
          this.city_index = x;
        }
      }
      this.insure_area = area[this.pro_index][this.city_index];
      for (var y in this.insure_area) {
        if (this.insure_area[y].label == this.insure.area) {
          this.area_index = y;
        }
      }
    },
    //第三者责任险
    selectIsThird(index) {
      if (index == 0) {
        this.Third = false;
        //三者和新机完工责任险绑定
        this.selectIsF(0);
        this.thirdPrice = 0;
      } else {
        if (this.info.is_third) {
          this.Third = true;
        } else {
          this.Third = false;
        }
        if (this.info.level[this.levelIndex].plan[this.fananIndex].third_data) {
          this.thirdPrice = this.info.level[this.levelIndex].plan[
            this.fananIndex
          ].third_data.price;
        }
      }
      this.is_third = index;
      this.countCost1();
    },
    //扩展火灾爆炸责任险
    selectIsFire(index) {
      this.is_fire = index;
      if (index == 1) {
        if (this.info.level[this.levelIndex].plan[this.fananIndex].fire_data) {
          this.firePrice = this.info.level[this.levelIndex].plan[
            this.fananIndex
          ].fire_data.price;
          console.log(this.firePrice);
        }
      } else {
        this.firePrice = 0;
      }

      this.countCost1();
    },
    //新机完工责任险
    selectIsF(index) {
      if (index == 0) {
        this.is_finished = false;
        this.finishedPrice = 0;
      } else {
        this.is_finished = true;
        if (this.info.level[this.levelIndex].plan[this.fananIndex].finished_data) {
          this.finishedPrice = this.info.level[this.levelIndex].plan[
            this.fananIndex
          ].finished_data.price;
        }
      }
      this.is_four = index;
      this.countCost1();
    },
    //盗抢险
    selectRob(index) {
      if (index == 0) {
        this.is_rob = false;
        this.robPrice = 0;
      } else {
        this.is_rob = true;
        if (this.info.level[this.levelIndex].plan[this.fananIndex].rob_data) {
          this.robPrice = this.info.level[this.levelIndex].plan[
            this.fananIndex
          ].rob_data.price;
        }
      }
      this.is_rob = index;
      this.countCost1();
    },
    //选择投保时长
    selectTime(index, item) {
      this.timeName = item.name;
      this.timeIndex = index;
      this.dtLevelIndex = index;
      if (this.fanan) {
        this.countCost1();
      }
    },
    //选择方案
    selectFanan(index, item) {
      //index 方案下标
      this.fanan = item.name;

      this.plan_id = item.id;
      console.log(this.plan_id, '保障方案的plan_id');
      // console.log("plan_id=" + this.plan_id);
      this.fananIndex = index;
      this.wg_name = this.info.level[this.levelIndex].plan[this.fananIndex].wg_name;
      this.flfy_name = this.info.level[this.levelIndex].plan[this.fananIndex].flfy_name;
      this.ylfy_name = this.info.level[this.levelIndex].plan[this.fananIndex].ylfy_name;
      this.zyjt_name = this.info.level[this.levelIndex].plan[this.fananIndex].zyjt_name;
      this.gzzrx_name = this.info.level[this.levelIndex].plan[this.fananIndex].gzzrx_name;

      this.countCost1();
      if (this.info.id == 9 || this.info.id == 15) {
        if (this.showTestFeatures) {
          this.cdzPrice = Number(this.cost)
        } else {
          this.cdzPrice = Number(this.cost) * this.stake.length;
        }
      }

      this.$forceUpdate();
    },
    // countCost(fananP, fireP, num, flag) {
    //   this.cdzPrice = (fananP + (flag ? fireP : 0)) * num;
    //   this.cost = fananP + (flag ? fireP : 0);
    //   console.log(this.cost);
    // },
    //等级方案
    selectDjFanan(item, index) {
      // this.djItem = item;
      this.min_num = item.min_num;
      this.level_id = item.id;
      this.level_name = item.name;
      if (this.info.id == 13) {
        this.levelIndex = index;
      }


      this.time_type = item.time_type;

      // this.dtLevelIndex = index;
      this.chooseDta = this.info.level[index];
      for (let i = 0; i < this.chooseDta.plan.length; i++) {
        if (this.fanan == this.chooseDta.plan[i].name) {
          this.plan_id = this.chooseDta.plan[i].id;

        }
      }

      // console.log("plan_id=" + this.plan_id);

      if (this.fanan) {
        this.countCost1();
      }
      this.selectStartTime();
      this.$forceUpdate();
    },
    getOrder() {
      let is_add = this.is_add ? 1 : 0;
      this.ajaxs("order/orderDetail", {
        data: {
          id: this.order_id,
          is_add: is_add,
        },
        success: (res) => {
          if (res.msg.mark != undefined) {
            arrList = res.msg.mark;
          }
          // this.info.level.forEach((item, index) => {
          //   if (item.name == res.msg.level) {
          //     this.djItem = item[index];
          //     this.min_num = this.djItem.min_num;
          //   }
          // });
          // this.info.dt_level.forEach((t) => {
          //   t.level.forEach((item, index) => {
          //     if (item.name == res.msg.level) {
          //       this.djItem = t[index];
          //       this.min_num = this.djItem.min_num;
          //     }
          //   });
          // });

          this.fanan = res.msg.fanan;
          this.is_third = res.msg.is_third ? true : false;
          this.is_four = res.msg.is_finished ? true : false;
          this.is_rob = res.msg.is_rob ? true : false;
          this.edit = false;
          this.insure = res.msg.insure;
          this.hyParam.insure = res.msg.insure;
          this.hyParam.insured = res.msg.insured;
          this.hyParam.goods = res.msg.goods;
          this.hyParam.transport = res.msg.transport;
          this.shParam.premises = res.msg.premises;
          this.shParam.merchant = res.msg.merchant;
          this.insure.edit = false;
          this.start_time = res.msg.start_time;
          this.plan_id = res.msg.plan_id;
          if (this.info.id == 9 || this.info.id == 15) {
            this.charge_info = res.msg.charge_info;
            this.charge_info.modelPGR =
              res.msg.charge_info.province +
              "/" +
              res.msg.charge_info.city +
              "/" +
              res.msg.charge_info.area;
          }
          this.insure.modelPGR =
            res.msg.insure.province +
            "/" +
            res.msg.insure.city +
            "/" +
            res.msg.insure.area;
          this.stake = res.msg.stake;
          this.user_edit = false;
          this.insureProfile_edit = false;
          this.stake_edit = false;
          this.insuredProfile_edit = false;

          this.yunProfile_edit = false;
          this.goodsProfile_edit = false;
          this.businessPlace_edit = false;
          this.elementProfile_edit = false;
          this.insuredBus_edit = false;
          this.cdzProfile_edit = false;
          this.is_fire = res.msg.is_fire;
          this.end_time = res.msg.end_time;
          this.time_eidt = false;
          this.user = this.info.id == 12 ? res.msg.protected : res.msg.user;
          this.user_edit = false;
          this.invoice = res.msg.invoice;
          this.invoice.edit = false;
          this.is_open = res.msg.is_open;
          this.open_arr = res.msg.open_arr ? res.msg.open_arr : [];
          this.level_name = res.msg.level;
          this.level_id = res.msg.level_id;
          this.info.level.forEach((item) => {
            if (item.id == this.level_id) {
              this.chooseDta = item;
            }
          })
            ;

          this.time_type = res.msg.time_type;

          this.key_from.license_key = res.msg.insure.img_key;
          this.key_from.personnel_key = res.msg.personnel_key;
          this.riskinfo = res.msg.riskinfo;
          if (this.showTestFeatures) {
            this.insured_check = res.msg.insured_check;
            this.property_type = res.msg.property_type;
            this.ccbe_arr.forEach((t) => {
              if (t.name == this.property_type) {
                this.ccbe_price = t.price;
              }
            })
          }

          // this.hyParam = res.msg.hyParam
          this.insureAddr();
          this.invoceIAddr();
          this.invoceIAddrs();
          this.getLevel();
          // if (!this.order_id) {
          //   this.selectDjFanan(this.djItem, this.levelIndex);
          // }
          this.countCost1();

          if (this.info.id == 9 || this.info.id == 15) {
            if (this.showTestFeatures) {
              this.cdzPrice = Number(this.cost)
              console.log(this.cost);

            } else {
              this.cdzPrice = Number(this.cost) * this.stake.length;
            }

          }

        },
      });
    },

    getData() {
      this.ajaxs("index/detail", {
        data: {
          id: this.id,
        },
        success: (res) => {
          this.info = res.msg;
          //三者
          console.log(this.info);
          //默认选中 投保
          if (this.info.third_true) {
            this.selectIsThird(1);
          }
          //完工责任
          if (this.info.finished_true) {
            this.selectIsF(1);
          }
          this.timeName = this.info.name;



          //this.djItem = this.info.level[0];
          this.level_id = this.info.level[0].id;
          this.plan_id = this.info.level[0].plan[0].id;
          if (this.showTestFeatures) {
            this.level_name = this.info.level[0].name
          }
          this.min_num = this.info.level[0].min_num;

          this.getHistory();
          if (this.order_id) {
            this.getOrder();
          }
          else {
            this.getStorage();
            this.chooseDta = this.info.level[0];
            this.fanan = this.chooseDta.plan[0].name
          }
          this.time_type = this.chooseDta.time_type;
          this.countCost1()
        },
      });
    },
  },
};
</script>

<style scoped>
@import "../../assets/css/index/form.css";

.xz /deep/ .el-dialog__header {
  padding: 0;
}

.xz /deep/ .el-dialog__body {
  padding: 30px 0;
}

.upload-img-file2 {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: 0;
  cursor: pointer;
}

.btns {
  margin-bottom: 20px;
  margin-left: 0;
  margin-right: 15px;
}
</style>
